<?php

require_once './core/tools.php';

if (isset($_POST["type"]) && isset($_POST["title"])){
	
	switch ($_POST["type"]){
		case "client":
			$query = "INSERT INTO versions_client(name) VALUES ('".$_POST["title"]."')";
			break;
		case "projet":
			$query = "INSERT INTO versions_projet(id_client, name) VALUES (".$_POST["id_client"].", '".$_POST["title"]."')";
			break;
		case "swf":
			$query = "INSERT INTO versions_swf(id_projet, name) VALUES (".$_POST["id_projet"].", '".$_POST["title"]."')";
			break;
	}

		
	$result = executeSQL($query);
	
	if (!$result){
		die ('{"error":1, "message":"MysqlError :'.addslashes(mysql_error()).'"}' );
	}
	
	echo '{"error":0, "message":"OK"}';
}
else {
	echo '{"error":2, "message":"missing parameters"}';
}


?>


